
package uk.addie.mp3fixer.widget;

import java.awt.event.ActionEvent;

import javax.swing.AbstractAction;
import javax.swing.JButton;
import javax.swing.JFileChooser;

import uk.addie.mp3fixer.MP3Fixer;

public class ChangeRoot extends AbstractAction {
    private static final long serialVersionUID = 1L;
    private JButton           mButton;

    public ChangeRoot() {
        super();
        putValue(NAME, "Change Root");
    }

    @Override public void actionPerformed(final ActionEvent e) {
        final JFileChooser jfc = new JFileChooser(MP3Fixer.getRoot().toFile());
        jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
        if (jfc.showOpenDialog(mButton) == JFileChooser.APPROVE_OPTION) {
            MP3Fixer.setRoot(jfc.getSelectedFile().toPath());
        }
    }
}
